package com.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

//@WebServlet(name = "ano",value = "/Ano")//根据需求配置所需属性
@WebServlet("/my/FirstServlet") //极简配置
public class ServletByAno extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        resp.setContentType("text/html;charset=utf-8");
        //业务代码
        PrintWriter out = resp.getWriter();
        out.print("servlet by Annotation<br>");
        out.println("<span style='color:red'>不经一番寒彻骨，怎得梅花扑鼻香！！！</span>");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);

    }
}
